// 读取一对正整数 a, b，求最大公约数；越界则输出 1
#include <stdio.h>

static int gcd(int x, int y)
{
    while (y != 0) {
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main(void)
{
    int a, b;
    if (scanf("%d %d", &a, &b) != 2) {
        return 0;
    }

    if (a <= 0 || b <= 0 || a >= 100000000 || b >= 100000000) {
        printf("1");
        return 0;
    }

    printf("%d", gcd(a, b));
    return 0;
}